package com.shunwang.errors.engine.core;
import java.util.HashMap;
import java.util.Map;

import com.shunwang.errors.engine.exception.BussException;
import com.shunwang.errors.engine.handler.Handler;
import com.shunwang.errors.engine.util.ThrowableUtil;

/**
 * @author hadoop20
 * @version 1.0
 * @created 19-10-2011 10:40:51
 */
public class Mapping {

	private Map<Throwable,Handler> mapping = new HashMap<Throwable,Handler>();

	public boolean contains(Throwable throwable){
		return mapping.containsKey(throwable);
	}

	public Handler getHandler(Throwable throwable){
		return mapping.get(throwable);
	}

	public void addMapping(Throwable throwable, Handler handler){
		ThrowableUtil.hasBussException(throwable);
		mapping.put(throwable, handler);
	}

	public void removeMapping(Throwable throwable){
		mapping.remove(throwable);
	}

}